package com.bruce.pattern.behavioral.visitor;

import com.bruce.pattern.behavioral.visitor.demo1.Computer;
import com.bruce.pattern.behavioral.visitor.demo1.ComputerPart;
import com.bruce.pattern.behavioral.visitor.demo1.ComputerPartDisplayVisitor;
import com.bruce.pattern.behavioral.visitor.demo2.*;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by bruce on 2018/11/11 19:48
 */
public class MainTest {

    @Test
    public void test1() {
        ComputerPart computer = new Computer();
        computer.accept(new ComputerPartDisplayVisitor());
    }

    @Test
    public void test2() {
        List<Course> courses = new ArrayList<>();

        FreeCourse freeCourse = new FreeCourse("java设计模式");
        courses.add(freeCourse);

        CodingCourse codingCourse = new CodingCourse("Java实战课程",55);
        courses.add(codingCourse);

        IVisitor visitor = new Visitor();

        for (Course cours : courses) {
            cours.accept(visitor);
        }

    }


}



















